package com.xy.webadmin.app.model.userEmail;

import com.baomidou.mybatisplus.annotation.*;
import com.xy.webadmin.upms.model.SysDept;
import com.xy.webadmin.upms.model.SysUser;
import com.xy.application.common.constant.EmailPlatform;
import com.xy.application.common.constant.YesOrNo;
import com.xy.common.core.upload.UploadStoreTypeEnum;
import com.xy.common.core.annotation.*;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 用户邮件信息实体对象。
 *
 * @author xiaoyue
 * @date 2025-05-13
 */
@Data
@TableName(value = "xy_user_email_received_info")
public class UserEmailReceivedInfo {

    /**
     * 主键。
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 邮件ID。
     */
    @TableField(value = "email_id")
    private String emailId;

    /**
     * 平台。
     */
    @TableField(value = "platform")
    private Integer platform;

    /**
     * 发件人邮箱。
     */
    @TableField(value = "sender")
    private String sender;

    /**
     * 收件人邮箱（多地址用分号分隔）。
     */
    @TableField(value = "receiver")
    private String receiver;

    /**
     * 邮件主题。
     */
    @TableField(value = "subject")
    private String subject;

    /**
     * 正文。
     */
    @TableField(value = "content")
    private String content;

    /**
     * 关键词。
     */
    @TableField(value = "keyword")
    private String keyword;

    /**
     * 是否为HTML格式。
     */
    @TableField(value = "is_html")
    private Integer isHtml;

    /**
     * 邮件发送时间。
     */
    @TableField(value = "send_time")
    private LocalDateTime sendTime;

    /**
     * 服务器收到邮件时间。
     */
    @TableField(value = "receive_time")
    private LocalDateTime receiveTime;

    /**
     * 处理状态。
     */
    @TableField(value = "status")
    private String status;

    /**
     * 优先级。
     */
    @TableField(value = "priority")
    private Integer priority;

    /**
     * 是否有附件。
     */
    @TableField(value = "has_attachment")
    private Integer hasAttachment;

    /**
     * 附件url。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
    @TableField(value = "attachment_url")
    private String attachmentUrl;

    /**
     * 系统用户。
     */
    @UserFilterColumn
    @TableField(value = "sys_user_id", fill = FieldFill.INSERT)
    private Long sysUserId;

    /**
     * 公司。
     */
    @DeptFilterColumn
    @TableField(value = "company_id")
    private Long companyId;

    /**
     * 创建时间。
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)

    private LocalDateTime createTime;

    /**
     * 更新时间。
     */

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 创建用户ID。
     */
    @TableField(value = "create_user_id", fill = FieldFill.INSERT)
    private Long createUserId;

    /**
     * 更新用户ID。
     */
    @TableField(value = "update_user_id", fill = FieldFill.INSERT_UPDATE)
    private Long updateUserId;

    /**
     * 逻辑删除标记字段(0: 正常 1: 已删除)。
     */
    @TableLogic
    @TableField(value = "is_deleted", fill = FieldFill.INSERT)
    private Integer isDeleted;

    /**
     * sendTime 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private String sendTimeStart;

    /**
     * sendTime 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private String sendTimeEnd;

    /**
     * receiveTime 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private String receiveTimeStart;

    /**
     * receiveTime 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private String receiveTimeEnd;

    @RelationDict(
            masterIdField = "sysUserId",
            slaveModelClass = SysUser.class,
            slaveIdField = "userId",
            slaveNameField = "showName")
    @TableField(exist = false)
    private Map<String, Object> sysUserIdDictMap;

    @RelationDict(
            masterIdField = "companyId",
            slaveModelClass = SysDept.class,
            slaveIdField = "deptId",
            slaveNameField = "deptName")
    @TableField(exist = false)
    private Map<String, Object> companyIdDictMap;

    @RelationConstDict(
            masterIdField = "platform",
            constantDictClass = EmailPlatform.class)
    @TableField(exist = false)
    private Map<String, Object> platformDictMap;

    @RelationConstDict(
            masterIdField = "isHtml",
            constantDictClass = YesOrNo.class)
    @TableField(exist = false)
    private Map<String, Object> isHtmlDictMap;

    @RelationConstDict(
            masterIdField = "hasAttachment",
            constantDictClass = YesOrNo.class)
    @TableField(exist = false)
    private Map<String, Object> hasAttachmentDictMap;
}
